<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>创建用户</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
</head>
<body>
<div th:replace="~{common/navbar :: navbar}"></div>

<div class="container mt-4">
    <div class="card">
        <div class="card-header">
            <h4><i class="bi bi-person-plus"></i> 创建新用户</h4>
        </div>
        <div class="card-body">
            <form th:action="@{/admin/users}" method="post">
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>

                <div class="mb-3">
                    <label for="userID" class="form-label">用户ID</label>
                    <input type="text" class="form-control" id="userID" name="userID" required>
                </div>

                <div class="mb-3">
                    <label for="userName" class="form-label">用户名</label>
                    <input type="text" class="form-control" id="userName" name="userName" required>
                </div>

                <div class="mb-3">
                    <label for="password" class="form-label">密码</label>
                    <input type="password" class="form-control" id="password" name="password" required>
                </div>

                <div class="mb-3">
                    <label for="email" class="form-label">邮箱</label>
                    <input type="email" class="form-control" id="email" name="email">
                </div>

                <div class="mb-3">
                    <label for="role" class="form-label">角色</label>
                    <select class="form-select" id="role" name="role" required>
                        <option th:each="role : ${roles}"
                                th:value="${role}"
                                th:text="${role == 'admin' ? '管理员' :
                                         (role == 'customer_service' ? '客服' : '客户')}">
                        </option>
                    </select>
                </div>

                <button type="submit" class="btn btn-primary">
                    <i class="bi bi-save"></i> 创建用户
                </button>
                <a href="/admin/users" class="btn btn-secondary ms-2">
                    <i class="bi bi-arrow-left"></i> 返回
                </a>
            </form>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
